<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="/luckydog/index">首页</a>
                        </li>
                        <li>
                            <a href="#">招聘管理</a>
                        </li>
                        <li class="active"> 招聘列表 </li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="tab-content tabs-flat no-padding">
                                <div id="visits" class="tab-pane active animated fadeInUp">
                                    <div class="row">
                                        <div class="col-lg-12 chart-container">
                                            <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                                <div class="widget-body">
                                                        <?php if(check_authorize("Jobs","List","add")):?>
                                                        <div style="float: right;">
                                                            <a href="/luckydog/jobs/textures" id="editabledatatable_new"   class=" btn btn-default">添加招聘信息</a>
                                                        </div>
                                                        <?php endif;?>
                                                        <div style="float: left;">
                                                        <label>开始时间：</label>
                                                        <label><input style="width:100px;" type="text" placeholder="起始时间" id="starttime" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'endtime\')||\'2120-10-01\'}'})" class="form-control" value="<?=$starttime?$starttime:date("Y-m-d",time())?>"></label>
                                                            </div>
                                                        <div style="float: left;">
                                                            <label>结束时间：</label>
                                                            <label><input style="width:100px;" type="text" placeholder="结束时间" id="endtime" onClick="WdatePicker({minDate:'#F{$dp.$D(\'starttime\')}',maxDate:'2120-10-01'})" class="form-control" value="<?=$endtime?$endtime:date("Y-m-d",time()+3600*24)  ?>"></label>
                                                        </div>
                                                        <div style="float: left; padding-left:10px;">
                                                            <div class="pull-left" style="line-height: 30px;margin-left: 10px;margin-bottom: 20px;">关键字：</div>
                                                            <input style="width:150px;" placeholder="关键词" id="keyword" type="text" class="form-control">
                                                        </div>
                                                        <div style="float: left;">
                                                            <a class="btn J_search" href="javascript:;">搜索</a>
                                                        </div>
                                                        <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                                            <thead>
                                                                <tr>
                                                                    <th>ID</th>
                                                                    <th>招聘职位</th>
                                                                    <th>招聘人数</th>
                                                                    <th>薪资待遇</th>
                                                                    <th>职位详情</th>
                                                                    <th>排序</th>
                                                                    <th>发布时间</th>
                                                                    <th>操作</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                            <tr>
                                                                <?php if(!empty($jobsList)):?>
                                                                    <?php foreach($jobsList as $key=> $row):?>
                                                                        <tr class="gradeX ">
                                                                            <td class="center"><?= $row['id']?></td>
                                                                            <td class="center" title="<?=$row['name']?>"><?= cutstr($row['name'],15)?></td>
                                                                            <td class="center"><?= $row['headcount']?></td>
                                                                            <td class="center"><?= $row['salary']?></td>
                                                                            <td class="center"><?= cutstr(strip_tags($row['content']),15)?></td>
                                                                            <td class="center"><?= $row['sort']?></td>
                                                                            <td class="center"><?=  date("Y-m-d h:i",$row['publishtime'])?></td>
                                                                            <td class="center " data_id = "<?= $row['id'];?>">
                                                                            <?php if(check_authorize("Jobs","List","edit")):?>
                                                                                <a href="/luckydog/jobs/textures?id=<?= $row['id'];?>" >编辑</a>&nbsp;|&nbsp;
                                                                            <?php endif;?>
                                                                            <?php if(check_authorize("Jobs","List","publish")):?>
                                                                                <a  href="javascript:;" class="J_onlinestatus" type="onlinestatus" onlinestatus="<?= $row['onlinestatus'];?>" >
                                                                            <?php if($row['onlinestatus'] == 1){?>
                                                                                下架
                                                                            <?php }elseif($row['onlinestatus'] == 0){?>
                                                                                上架
                                                                            <?php }?>
																				</a>&nbsp;|
                                                                            <?php endif;?>
                                                                            <?php if(check_authorize("Jobs","List","delete")):?>
                                                                                <a href="javascript:;" class="J_del">删除</a>
                                                                            <?php endif;?>
                                                                            </td>
                                                                        </tr>
                                                                    <?php endforeach;?>
                                                                <?php endif;?>
                                                            </tr>
                                                            <tr><td style="text-align: center;" colspan="7"><?=$page_links?></td></tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>

       
        <!-- /Page Content -->
<script src="<?= STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?= STATICURL; ?>layer/layer.js"></script>
<script src="<?php echo STATICURL; ?>js/wdatepicker/WdatePicker.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
    $('.edit_account').on('click', function(){
        //iframe窗
        var id = $(this).parent().attr("data_id");
        var type = 1;
        var height = '550px';
        $("#myTab li").each(function(){
            if($(this).hasClass('active')){
                type = $(this).attr('data-type');
            }
        });
        if(type == 2){
            height = '360px';
        }
        var title = "修改";
        if(id == undefined){
            id = "";
            title = "添加";
        }
        
        layer.open({
            type: 2,
            title: title,
            shade: [0.5, '#000'],
            shadeClose: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['750px', height],
            content: '/luckydog/news/textures?id='+id+'&type='+type
        });
    });

   

    $(".J_search").click(function(){
            var endtime = $("#endtime").val();
            var starttime = $("#starttime").val();
            var keyword = $("#keyword").val();
            var params={
                'endtime':endtime,
                'starttime':starttime,
                'keyword':keyword,
            };
            location = "/luckydog/jobs/index?"+$.param(params);
        });
    $(document).ready(function() {

        $(".J_del").click(function() {
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要删除吗？")) {
                $.post("/luckydog/jobs/delJobs", {"id":id}, function(res) {
                    if (res) {
                        layer.msg("删除成功");
                        window.location.reload();
                    }else{
                        layer.msg("删除失败");
                    }
                });
            }
        });

        $(".J_onlinestatus").click("click",function(){
            var id = $(this).parent().attr("data_id");
            var onlinestatus = $(this).attr("onlinestatus");
            var des = "确定上架吗？";
            if(onlinestatus == 1){
                onlinestatus = 0;
                des = "确定要下架吗？";
            }else{
                onlinestatus = 1;
            }
            if(confirm(des)){
                $.post("/luckydog/jobs/editStatus",{"id":id,"onlinestatus":onlinestatus,"type":"onlinestatus"},function(res){
                    if(res){
                        layer.msg("成功");
                         window.location.reload();
                    }else{
                        alert("失败");
                    }
                });
            }
        });
    });

</script>


